package main

import (
	"fmt"
	"go-learn/config"
	"go-learn/global"
	"go-learn/initialize"
	"go-learn/model/pb"
	"time"
)

/*
	1.测试SetConnMaxLifetime（连接复用时长）和mysql超时之间的设置影响
	2.测试长连接在结束后是否会立即销毁和销毁的条件
*/
func main() {
	global.Config = config.Init()
	global.GvaMysql = initialize.Mysql()

	for {
		findAll()
		fmt.Println(global.GvaMysql)
		for i := 0; i < 10; i++ {
			time.Sleep(1 * time.Second)
			fmt.Println(i)
		}
		time.Sleep(time.Hour)
	}
}
func findAll() {
	sql := "select * from user"
	var users []pb.User
	err := global.GvaMysql.Select(&users, sql)
	if err != nil {
		fmt.Printf("findAll failed!!!,err:%s", err)
		return
	}
	fmt.Println(users)
}
